home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / xcmd / macintal.sit / Globals Stack / card_2875.txt < prev    next >
Encoding:
Text File  |  1989-05-27  |  6.1 KB  |  224 lines

  1. -- card: 2875 from stack: in
  2. -- bmap block id: 3320
  3. -- flags: 0000
  4. -- background id: 2619
  5. -- name: Start
  6. ----- HyperTalk script -----
  7. on openCard
  8.   set the scroll of card field "desc" to 0
  9. end openCard
  10.  
  11.  
  12. -- part 4 (field)
  13. -- low flags: 01
  14. -- high flags: 0007
  15. -- rect: left=21 top=106 right=313 bottom=492
  16. -- title width / last selected line: 0
  17. -- icon id / first selected line: 0 / 0
  18. -- text alignment: 0
  19. -- font id: 4
  20. -- text size: 9
  21. -- style flags: 0
  22. -- line height: 12
  23. -- part name: desc
  24.  
  25.  
  26. -- part 6 (button)
  27. -- low flags: 00
  28. -- high flags: 8003
  29. -- rect: left=21 top=318 right=340 bottom=121
  30. -- title width / last selected line: 0
  31. -- icon id / first selected line: 0 / 0
  32. -- text alignment: 1
  33. -- font id: 0
  34. -- text size: 12
  35. -- style flags: 0
  36. -- line height: 16
  37. -- part name: Install╔
  38. ----- HyperTalk script -----
  39. on mouseUp
  40.   answer "Install into Home stack?" with "Cancel" or "No" or "Yes"
  41.   if it = "Cancel" then
  42.     answer "Installation Cancelled" with "OK"
  43.     exit mouseUp
  44.   else if it = "Yes" then
  45.     put true into HomePath
  46.     put word 2 of the long name of stack "Home" into tmp
  47.     delete char 1 of tmp
  48.     delete last char of tmp
  49.     put tmp into DestPath
  50.   else
  51.     put false into HomePath
  52.     put StandardFile("get", "STAK") into DestPath
  53.     if DestPath = "" then
  54.       answer "Installation Cancelled" with "OK"
  55.       exit mouseUp
  56.     end if
  57.   end if
  58.   put word 2 of the long name of this stack into tmp
  59.   delete char 1 of tmp
  60.   delete last char of tmp
  61.   put tmp into MyPath
  62.   DoCopy MyPath,DestPath,"XPRC","Globals"
  63.   DoCopy MyPath,DestPath,"XPRC","PGlobals"
  64.   DoCopy MyPath,DestPath,"XCMD","ZapGlobals"
  65.   if HomePath then
  66.     answer "Edit script of Home stack to 'ZapGlobals'?" with "No" or "Yes"
  67.     if it = "No" then
  68.       hide msg
  69.       exit mouseUp
  70.     end if
  71.     EditScript DestPath
  72.   end if
  73.   hide msg
  74. end mouseUp
  75.  
  76.  
  77.  
  78. -- part 8 (field)
  79. -- low flags: 01
  80. -- high flags: 0002
  81. -- rect: left=368 top=22 right=97 bottom=509
  82. -- title width / last selected line: 0
  83. -- icon id / first selected line: 0 / 0
  84. -- text alignment: 1
  85. -- font id: 3
  86. -- text size: 9
  87. -- style flags: 0
  88. -- line height: 12
  89. -- part name: 
  90.  
  91.  
  92. -- part 9 (field)
  93. -- low flags: 01
  94. -- high flags: 0000
  95. -- rect: left=2 top=22 right=46 bottom=320
  96. -- title width / last selected line: 0
  97. -- icon id / first selected line: 0 / 0
  98. -- text alignment: 1
  99. -- font id: 3
  100. -- text size: 18
  101. -- style flags: 768
  102. -- line height: 24
  103. -- part name: 
  104.  
  105.  
  106. -- part 10 (field)
  107. -- low flags: 01
  108. -- high flags: 0000
  109. -- rect: left=2 top=52 right=72 bottom=320
  110. -- title width / last selected line: 0
  111. -- icon id / first selected line: 0 / 0
  112. -- text alignment: 1
  113. -- font id: 3
  114. -- text size: 14
  115. -- style flags: 768
  116. -- line height: 18
  117. -- part name: 
  118.  
  119.  
  120. -- part 12 (field)
  121. -- low flags: 01
  122. -- high flags: 0000
  123. -- rect: left=2 top=79 right=97 bottom=320
  124. -- title width / last selected line: 0
  125. -- icon id / first selected line: 0 / 0
  126. -- text alignment: 1
  127. -- font id: 3
  128. -- text size: 12
  129. -- style flags: 0
  130. -- line height: 16
  131. -- part name: 
  132.  
  133.  
  134. -- part 13 (button)
  135. -- low flags: 00
  136. -- high flags: 8003
  137. -- rect: left=129 top=318 right=340 bottom=229
  138. -- title width / last selected line: 0
  139. -- icon id / first selected line: 0 / 0
  140. -- text alignment: 1
  141. -- font id: 0
  142. -- text size: 12
  143. -- style flags: 0
  144. -- line height: 16
  145. -- part name: Sample╔
  146. ----- HyperTalk script -----
  147. on mouseUp
  148.   go card "Sample"
  149. end mouseUp
  150.  
  151.  
  152.  
  153. -- part 14 (button)
  154. -- low flags: 00
  155. -- high flags: 0001
  156. -- rect: left=0 top=19 right=49 bottom=38
  157. -- title width / last selected line: 0
  158. -- icon id / first selected line: 28023 / 28023
  159. -- text alignment: 1
  160. -- font id: 0
  161. -- text size: 12
  162. -- style flags: 0
  163. -- line height: 16
  164. -- part name: Home Base
  165. ----- HyperTalk script -----
  166. on mouseUp
  167.   visual effect barn door close
  168.   go stack "Home Base"
  169. end mouseUp
  170.  
  171.  
  172.  
  173. -- part contents for card part 4
  174. ----- text -----
  175. Preserving the values of global variables between separate calls of XCMDs or XFCNs is not easy - where do you store the values? This stack provides a solutionΓǪ
  176.  
  177. ΓÇó  an XCMD "ZapGlobals" - see ZapGlobals below.
  178.  
  179. ΓÇó  two code resources (type XPRC), ΓÇ£GlobalsΓÇ¥ for C and ΓÇ£PGlobalsΓÇ¥ for ┬á┬á┬áPascal, which provide a globals storage service. These are both code ┬á┬á┬áresources with an entry point at their start and are of type:
  180.  
  181. ┬á┬á┬á┬á┬á┬áHandle Globals(int selector, long id, long size);
  182. ┬á┬á┬á┬á┬á┬áfunction PGlobals(selector : int; id, size : LongInt) : Handle;
  183.  
  184. ┬á┬á┬áIn C they may be loaded by:
  185.  
  186. ┬á┬á┬á┬á┬á┬áprocHandle = GetNamedResource('XPRC', "\pGlobals");
  187.       LoadResource(procHandle);
  188.       HLock(procHandle);
  189.  
  190. ┬á┬á┬áThere are three functions:
  191.  
  192. ┬á┬á┬á┬░  GetGlobals: selector = 1. 'id' should be a unique identifier for ┬á┬á┬á┬á┬á┬áyour global storage, 'size' is the number of bytes to allocate if ┬á┬á┬á┬á┬á┬áthe globals don't already exist - if zero nothing will be allocated. ┬á┬á┬á┬á┬á┬áThe result is a handle (unlocked) to your global storage, or NIL if ┬á┬á┬á┬á┬á┬áthere was an error or the globals don't exist and 'size' was zero. ┬á┬á┬á┬á┬á┬áFor example:
  193.  
  194. ┬á┬á┬á┬á┬á┬á   h = (**procHandle)(1, 'talk', sizeof struct talkdata);
  195.  
  196. ┬á┬á┬á┬░  FreeGlobals: selector = 2. 'id' as above, 'size' unused (may be ┬á┬á┬á┬á┬á┬áomitted in C but NOT in Pascal!). Removes the globals and ┬á┬á┬á┬á┬á┬ádeallocates their memory. Returns NIL. For example:
  197.  
  198. ┬á┬á┬á┬á┬á┬á   (**procHandle)(2, 'talk');
  199.  
  200. ┬á┬á┬á┬░  ZapGlobals: selector = 3, 'id' and 'size' unused. Removes all ┬á┬á┬á┬á┬á┬áglobals but DOES NOT deallocate their memory. This is called (via ┬á┬á┬á┬á┬á┬áthe 'ZapGlobals' XCMD) on HyperCard shutdown and suspension - ┬á┬á┬á┬á┬á┬ámessages 'quit' and 'suspend'. You shouldn't need to call this
  201. ┬á     yourself.
  202.  
  203. These two XPRCs and the XCMD may be installed in your Home stack, so all XCMDs and XFCNs can use them, by pressing the "InstallΓǪ" button. A sample C interface to these routines may be seen by pressing "SampleΓǪ"
  204.  
  205. -- part contents for card part 8
  206. ----- text -----
  207. Nigel Perry
  208. Dept of Computing
  209. Imperial College
  210. London SW7
  211.  
  212. email: np@uk.ac.ic.doc
  213.  
  214. -- part contents for card part 9
  215. ----- text -----
  216. (P)Globals
  217.  
  218. -- part contents for card part 10
  219. ----- text -----
  220. A Utility for HyperTalk Programmers
  221.  
  222. -- part contents for card part 12
  223. ----- text -----
  224. ┬⌐1989, Nigel Perry, Portions ┬⌐ Think